﻿using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PsTFS.Commandes.Get;

namespace PsTFS.CmdLet.UnitTests
{
    [TestClass]
    public class GetWIsUnitTests
    {
        [TestMethod]
        public void SimpleQuery()
        {
            Assert.AreEqual(GetFormattedPath("My Bugs"), "My Bugs");
        }

        [TestMethod]
        public void ValidFolderPathQuery()
        {
            Assert.AreEqual(GetFormattedPath("Current Iteration/My Work Item Query"), "«Current Iteration» My Work Item Query");
        }

        [TestMethod]
        public void ValidFolderSubPathQuery()
        {
            Assert.AreEqual(GetFormattedPath("Project/Sub project/My Query"), "«Project⁄Sub project» My Query");
        }

        [TestMethod]
        public void Valid2013FolderFormatWithSubPathQuery()
        {
            Assert.AreEqual(GetFormattedPath("«WebDevelopment/Testing» Web - Trunk Query"), "«WebDevelopment/Testing» Web - Trunk Query");
        }

        [TestMethod]
        public void Valid2013FolderFormatQuery()
        {
            Assert.AreEqual(GetFormattedPath("«WebDevelopment» Web - Trunk Query"), "«WebDevelopment» Web - Trunk Query");
        }

        [TestMethod]
        public void ValidFolderWithAbsolutePathQuery()
        {
            Assert.AreEqual(GetFormattedPath("/Current Iteration/My Work Item Query"), "«Current Iteration» My Work Item Query");
        }

        private string GetFormattedPath(string query)
        {
            var s = new GetWIs {StoredQuery = query}.FormattedQuery;
            Debug.Write(s);
            return s;
        }
    }
}
